package cn.itcast.java;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * Author itcast
 * Date 2021/10/9 22:11
 * Desc TODO
 */
public class CalendarDemo {
    public static void main(String[] args) {
        Calendar c = Calendar.getInstance();
        int date = c.get(Calendar.DATE);
        System.out.println(date);
        int month = c.get(Calendar.MONTH);
        System.out.println(month+1);
        int hour = c.get(Calendar.HOUR);
        System.out.println(hour);
        Date time = c.getTime();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String format = sdf.format(time);
        System.out.println(format);
    }
}
